<template>
  <div class="tab-bar-item" @click="itemClick">
    <slot v-if="!isActive" name="item-icon"></slot>
    <slot v-else name="item-icon-active"></slot>
    <div :style="activeStyle">
      <slot name="item-name"></slot>
    </div>

  </div>

</template>

<script>
export default {
  name: "TabBarItem",
  props: {
    path: String,
    activeClass: {
      type: String,
      default: 'red'
    }
  },
  data() {
    return {
      /* isActive:true*/

    }
  },
  methods: {
    itemClick() {
      this.$router.replace(this.path)
    }
  }, computed: {
    isActive() {
      return this.$route.path.indexOf(this.path) !== -1
    }, activeStyle() {
      return this.isActive ? {color : this.activeClass}:{}
    }
  }


}
</script>

<style scoped>
.tab-bar-item {
  flex: 1;
  text-align: center;
  height: 49px;
  font-size: 14px;
}

.tab-bar-item img {
  height: 24px;
  width: 24px;
}

/*.active {
  color: red;
}*/
</style>
